﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MenuImplementation
{
    class Program
    {
        static void Main(string[] args)
        {
            // Menu
            int select;
            do
            {
                Console.Clear();
                Console.WriteLine("1 - Counting the amount of positive, negative and zero numbers.");
                Console.WriteLine("2 - List of double-digit multiples of 5.");
                Console.WriteLine("3 - Determine the number of digits and min/max digit in the number.");
                Console.WriteLine("4 - List of square numbers from 10 to 20.");
                Console.WriteLine("5 - Maximum number from 5 numbers.");
                Console.WriteLine("6 - Amoeba count.");
                Console.WriteLine("7 - Calculation of deposit under 3% per annum.");
                Console.WriteLine("8 - List of natural number from 20 to 50, which are divided into 3, but not divisible by 5.");
                Console.WriteLine("9 - Reverse number.");
                Console.WriteLine("10 - Find maximum number of array.");
                Console.Write("Select program: ");
                select = Int32.Parse(Console.ReadLine());

                switch (select)
                {
                    case 1:
                        PrintIntToConsole();
                        break;
                    case 2:
                        NumbersDiv5();
                        break;
                    case 3:
                        DigitsInNumber();
                        break;
                    case 4:
                        Sqr();
                        break;
                    case 5:
                        MaxNumber();
                        break;
                    case 6:
                        Amoeba();
                        break;
                    case 7:
                        Deposit();
                        break;
                    case 8:
                        NaturalNumber();
                        break;
                    case 9:
                        ReversedNumber();
                        break;
                    case 10:
                        MaxNumberInArray();
                        break;
                }
            }
            while (select <= 0 || select > 10);
        }

        // Find amount of zero, negative and positive numbers
        static void PrintIntToConsole()
        {
            Console.Clear();

            int positiveCount = 0;
            int negativeCount = 0;
            int zeroCount = 0;

            Console.Write("Enter count of numbers: ");
            int count = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Enter numbers");

            for (int i = count; i > 0; i--)
            {
                int number = Int32.Parse(Console.ReadLine());
                if (number == 0)
                {
                    zeroCount++;
                }
                if (number > 0)
                {
                    positiveCount++;
                }
                if (number < 0)
                {
                    negativeCount++;
                }
            }

            Console.WriteLine("Zero Counts {0}, Negative Counts {1}, PositiveCounts {2}", zeroCount, negativeCount, positiveCount);
        }

        // List of two-digit numbers that are multiples of 5
        static void NumbersDiv5()
        {
            Console.Clear();
            for (int k = -10; k > -99; k--)
            {
                if (k % 5 == 0)
                {
                    Console.WriteLine(k);
                }
            }

            for (int i = 10; i <= 99; i++)
            {
                if (i % 5 == 0)
                {
                    Console.WriteLine(i);
                }
            }
        }

        // Find amount of digits in the number, max and min digit from the number
        static void DigitsInNumber()
        {
            Console.Clear();
            int counter = 1;
            int max = 0;
            int min = 9;
            Console.Write("Enter number: ");
            int number = Int32.Parse(Console.ReadLine());

            while (number / 10 > 0)
            {
                counter++;
                int digit = number % 10;
                number = number / 10;
                if (digit > max)
                {
                    max = digit;
                }
                if (digit < min)
                {
                    min = digit;
                }
            }

            if (number > max)
            {
                max = number;
            }
            if (number < min)
            {
                min = number;
            }

            Console.WriteLine("Number {0} includes {1} digits. Max digit: {2}, Min digit {3}", number, counter, max, min);
        }

        //List of squares numbers from 10 to 20
        static void Sqr()
        {
            Console.Clear();
            for (int i = 10; i <= 20; i++)
            {
                Console.WriteLine(i * i);
            }
        }

        // Find the maximum number of five numbers entered
        static void MaxNumber()
        {
            int max = Int32.MinValue;
            int number = 0;
            for (int i = 0; i < 5; i++)
            {
                Console.Write("Enter number: ");
                number = Int32.Parse(Console.ReadLine());
                if (number > max)
                {
                    max = number;
                }
            }
            Console.WriteLine("Maximum number is {0}", max);
        }

        // Amoeba every 3 hours divided into 2 cells. How many amoebas will be at 3, 6, 9, 12, ..., 24 hours?
        static void Amoeba()
        {
            Console.Clear();
            int amoeba = 1;
            for (int h = 3; h <= 24; h += 3)
            {
                amoeba = amoeba * 2;
                Console.WriteLine("After {0} hours will be {1} amoebas", h, amoeba);
            }
        }

        // Calculation of deposit under 3% per annum
        static void Deposit()
        {
            Console.Clear();
            Console.Write("Enter amount of UAH: ");
            decimal S = Decimal.Parse(Console.ReadLine());
            Console.Write("Enter amount of years: ");
            decimal N = Decimal.Parse(Console.ReadLine());
            decimal Sn = S + N * S * (decimal)0.03;
            Console.WriteLine("After {0} years will be {1:0.##} UAH.", N, Sn);            
        }

        // Return list of natural number from 20 to 50, which are divided into 3, but not divisible by 5
        static void NaturalNumber()
        {
            Console.Clear();
            for(int i = 20; i <= 50; i++)
            {
                if (i % 3 == 0 && i % 5 != 0)
                {
                    Console.WriteLine(i);
                }
            }
        }

        // Return reversed nubmer from input
        static void ReversedNumber()
        {
            Console.Clear();
            Console.Write("Enter number: ");
            int number = Int32.Parse(Console.ReadLine());
            Console.Write("Reversed number: ");
            while (number > 0)
            {
                int digit = number % 10;
                Console.Write(digit);
                number = number / 10;
            }
        }

        static void MaxNumberInArray()
        {
            Console.Clear();
            Console.WriteLine("Enter 5 numbers");
            int max = Int32.MinValue;
            int number = 0;
            int[] numbers = new int[5];
            for(int i = 0; i<5; i++)
            {
                Console.Write("Enter number: ");
                number = Int32.Parse(Console.ReadLine());
                if (number > max)
                {
                    max = number;
                }
            }
            Console.WriteLine("Maximum number is {0}", max);
        }
    }
}